﻿#include "des.h"
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	des *my_des = new des();
	//set key
	my_des->initkey("12345678");
	printf("key is :\n12345678\n\n");

	//----------------------------test any lenth---------------------------
	const char *anyLenTest = "any length test of yxyDES2! a test, a test!";

	printf("Test anylenth: %d\n%s\n", strlen(anyLenTest), anyLenTest);

	//encrypt
	my_des->DESencrypt(anyLenTest, strlen(anyLenTest));

	char hex[8192];
	char bin[8192];
	memset(hex, 0, 8192);
	memset(bin, 0, 8192);
	my_des->getciphbin(bin);
	printf("bin:\n%s\n", bin);
	my_des->getciphhex(hex);
	printf("hex:\n%s\n", hex);

	//decrypt
	char buf1[8192] = "69a928f31a9e0644838009f9dfb64915";
	//char *p = my_des->getciphbin(buf1);
	

	char buf[8192];
	memset(buf, 0, 8192);

	my_des->DESdecrypt(buf, buf1, strlen(buf1), ECIPHHEX);
	printf("After decrypt:\n%s\n", buf);

	delete my_des;

	return 0;
}

